package com.kjs.web.cacheService;

import com.kjs.common.resultModel.JwtUser;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.security.core.userdetails.UserDetailsService;

/**
 * @author xuedingjiexueergou@gmail.com
 * @date 2018/10/16 9:54
 */
@CacheConfig(
        cacheNames = {"jwt_user"}
)
public interface IJwtUserCacheService extends UserDetailsService {
    @Cacheable(
            key = "#id",
            unless = "#result==null"
    )
    JwtUser findJwtUserById(Integer id);

    @CachePut(key = "#id", value = "user",unless = "#result==null")
    JwtUser save(JwtUser user);
}
